<?php include("include.php");?>
<?php

$userProject = project::getProjectByUserId($currentUser->getId());
?>
<h1>Welcome to Your Main Dashboard</h1>
<?php errorCheck()?>
<div id="contentPane">
<div id="tableTitle"><a href="createProject.php?"><img src="images/add-icon.png" /></a>Project</div>
<div class="list">
<table>

<tr>
	<th>Project ID</th>
    <th>Project Title</th>
    <th>Edit</th>
    <th>Jobs</th>
    <th>Delete</th>
</tr>
<?php

while($row = $userProject->fetch_assoc()){
	$tempProject = new Project($row['id'],$row['user_id'],$row['title'],$row['created_at'],$row['updated_at']);
	
//go through every SQL row in the result set
	echo "<tr class=\"data\">";
		echo "<td>".$tempProject->getId()."</td>";
		echo "<td>".$tempProject->getTitle()."</td>";
		echo "<td><a href=\"editProject.php?pid=".$tempProject->getId()."\"><img src=\"images/edit-icon.png\"></a></td>";	
		echo "<td><a href=\"dashboard.php?projectid=".$tempProject->getId()."\"><img src=\"images/detail-icon.png\"></a></td>";			
		echo "<td><a href=\"deleteProjectAction.php?pid=".
				$tempProject->getId()."\"><img src=\"images/delete-icon.png\"></a></td>";
	echo "</tr>\n";
	unset($tempProject);
}
?>
</table>
</div>
</div>
<?php include("includes/footer.php");?>